package com.hqyj.javaGraduation.hotel.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hqyj.javaGraduation.hotel.pojo.HotelComService;
import com.hqyj.javaGraduation.hotel.pojo.HotelMaterials;
import com.hqyj.javaGraduation.hotel.pojo.HotelTable;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 原材料dao
 */
@Mapper
@Repository
public interface HotelMaterialsDao extends BaseMapper<HotelMaterials> {

    @Select("select mat_id,mat_number from hotel_materials")
    List<HotelMaterials> queryMat();

    //联表查询 通过原材料id查出对应供应商及供应商所售商品信息
    @Select("SELECT mat_id,mat_name,mat_number,sup_name,sup_manager,sup_iphone,sup_partner,com_name,com_price,com_id\n" +
            "FROM hotel_materials LEFT JOIN hotel_mat_sup \n" +
            "ON mat_id=matt_id LEFT JOIN hotel_supplier\n" +
            "ON supp_id=sup_id LEFT JOIN hotel_sup_com \n" +
            "ON sup_id=ssup_id LEFT JOIN hotel_commodity \n" +
            "ON ccom_id=com_id\n" +
            "where mat_id = #{matId}")
    IPage<HotelComService> matSupList(IPage<HotelComService> page ,int matId);

    @Select("SELECT mat_number FROM hotel_materials WHERE mat_id= #{matId}")
    int selID(int matId);
}
